
//
//  String+Extensions.swift
//  VVbo
//
//  Created by Mr.Run on 2017/9/6.
//  Copyright © 2017年 Mr.Run. All rights reserved.
//

import Foundation

extension String {
    
    func vv_href()->(link: String, text:String)? {
        let pattern = "<a href=\"(.*?)\".*?>(.*?)</a>"
        
        guard let regx = try? NSRegularExpression(pattern: pattern, options: []),
            let result = regx.firstMatch(in: self, options: [], range: NSRange(location: 0, length: characters.count))
            else{
            return nil
        }
        let link = (self as NSString).substring(with: result.rangeAt(1))
        let text = (self as NSString).substring(with: result.rangeAt(2))
        return(link, text)
    }
    
}
